package com.leiou.stu_login;

import com.leiou.pojo.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.function.Consumer;

//     学生登录
@WebServlet("/stulog")
public class stuLogHandler extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
//        用什么方式显示汉字
        resp.setContentType("text/html;charset=UTF-8");

//        String id=req.getParameter("studentId");
        String account=req.getParameter("account");
        String password=req.getParameter("password");

        stuLogDao stuLogDao=new stuLogDaoImpl();
        Student login = stuLogDao.login(account, password);
        System.out.println(">>>>>"+login);
        if (login!=null){
            resp.getWriter().write("Y");
        }else {
            resp.getWriter().write("N");
        }

    }
}
